package panda.rmi.client.impl;

import java.sql.ResultSetMetaData;
import java.sql.SQLException;

import panda.rmi.client.ResultSetAdapter;
import panda.rmi.server.ServerMetaData;
import panda.rmi.server.ServerResultSet;

public class PandaResultSet extends ResultSetAdapter {
	ServerResultSet rs;
	
	PandaResultSet(ServerResultSet rs) {
		this.rs = rs;
	}
	
	public boolean next() throws SQLException {
		try {
			return rs.next();
		}
		catch (Exception e) {
			throw new SQLException(e);
		}
	}
	
	public int getInt(String attr) throws SQLException {
		try {
			return rs.getInt(attr);
		}
		catch (Exception e) {
			throw new SQLException(e);
		}
	}
	
	public String getString(String attr) throws SQLException {
		try {
			return rs.getString(attr);
		}
		catch (Exception e) {
			throw new SQLException(e);
		}
	}
	
	public ResultSetMetaData getMetaData() throws SQLException {
		try {
			ServerMetaData md = rs.getMetaData();
			
			return new PandaMetaData(md);
		}
		catch (Exception e) {
			throw new SQLException(e);
		}
	}
}
